<?php

/* 品牌 cate */
class CategoryModel extends BaseModel
{
    var $table  = 'category';
    var $prikey = 'cate_id';
    var $_name  = 'cate';
	
    var $_relation = array(
		'has_news' => array(
            'model'         => 'news',
            'type'          => HAS_MANY,
            'foreign_key'   => 'cate_id',
            'dependent'     => true
        ),
	);

        /*
     * 判断名称是否唯一
     */
    function unique($cate_name, $cate_id = 0)
    {
        $conditions = "cate_name = '" . $cate_name . "' AND cate_id != ".$cate_id."";
        return count($this->find(array('conditions' => $conditions))) == 0;
    }
}

?>